<?php
/**
 * Create by PhpStorm
 * User: lijia
 * Data: 2020/8/10
 * Time: 10:52
 */

namespace app\api\business;


use app\api\controller\UserCommon;
use app\api\model\UserCoupon;
use think\facade\Db;

class CouponBus extends UserCommon
{
    public $model;
    public function __construct(){
        parent::__construct();
        $this->model = new UserCoupon();
    }

    public function getList($status){
        if ($status){
            $where[] = ['a.status','=',$status];
        }
        $where[] = ['a.user_id','=',$this->user_id];
        $list = Db::name('user_coupon')->alias('a')
            ->join('coupon b','b.id = a.coupon_id','left')
            ->field('a.*,b.coupon_price,b.title,b.desc')
            ->where($where)->select();
        return $list;
    }

}